import unittest
from time import sleep
from Page.Page import Page
from Page.Page2 import Page2
from Page.Page1 import Page1
from selenium.webdriver.common.by import By
from selenium import webdriver

class TestCase(unittest.TestCase):
    def setUp(self) -> None:
        self.driver=webdriver.Edge()
        self.driver.maximize_window()
        self.driver.implicitly_wait(5)
    def tearDown(self) -> None:
        sleep(8)
        self.driver.quit()

    def test_01_search(self):
        po=Page(self.driver)
        po.open_url('https://m.mall.360.cn/')
        po.login()
        sleep(1)
        po.zhanghao()
        sleep(1)
        po.phone()
        sleep(1)
        po.pwd()
        sleep(1)
        po.xieyi()
        sleep(1)
        po.l()
        sleep(5)
        # 断言1
        dy1 = (By.XPATH, '//*[@id="body"]/div[1]/div[2]/div/div[2]/div[2]/a')
        print(dy1)
        self.assertTrue(dy1,"360U3506130998")
        po.shuru()
        sleep(1)
        po.shuru1()
        sleep(1)
        #断言2
        dy2=(By.LINK_TEXT,'家用电器')
        print(dy1)
        self.assertNotEqual(dy2,'11')
    # def test_02_cart(self):
    #     po=Page1(self.driver)
    #     po.open_url('https://m.mall.360.cn/')
    #     po.login()
    #     sleep(1)
    #     po.zhanghao()
    #     sleep(1)
    #     po.phone()
    #     sleep(1)
    #     po.pwd()
    #     sleep(1)
    #     po.xieyi()
    #     sleep(1)
    #     po.l()
    #     sleep(6)
    #     po.huadong()
    #     sleep(2)
    #     # 断言6
    #     # dy6 = (By.XPATH, '//*[@id="body"]/div[4]/div[1]/div[2]/div[1]/span[1]')
    #     # print(dy6)
    #     # self.assertNotIn(dy6, '11')
    #     po.tu()
    #     sleep(1)
    #     po.switch()
    #     sleep(2)
    #     # 断言5
    #     # dy5 = (By.XPATH, '//*[@id="body"]/div[4]/div/div[1]/div[2]/div[1]/div[3]/div[3]/div[1]/div[1]')
    #     # print(dy5)
    #     # self.assertFalse(dy5, '11')
    #     po.cart()
    # def test_03_address(self):
    #     po=Page2(self.driver)
    #     po.open_url('https://m.mall.360.cn/')
    #     po.login()
    #     sleep(1)
    #     po.zhanghao()
    #     sleep(1)
    #     po.phone()
    #     sleep(1)
    #     po.pwd()
    #     sleep(1)
    #     po.xieyi()
    #     sleep(1)
    #     po.l()
    #     sleep(8)
    #     po.wode()
    #     sleep(2)
    #     po.address()
    #     sleep(2)
    #     po.switch()
    #     sleep(1)
    #     # # 断言3
    #     # dy3=(By.XPATH,'//*[@id="app"]/div[2]/div[2]/table/thead/tr/th[4]')
    #     # print(dy3)
    #     # self.assertIn(dy3,'地址')
    #     po.address1()
    #     sleep(2)
    #     # 断言4
    #     # dy3 = (By.XPATH, '//*[@id="ngdialog1"]/div[2]/h3')
    #     # print(dy3)
    #     # self.assertNotIn(dy3, '哈哈哈')
    #     po.name()
    #     sleep(1)
    #     po.address2()
    #     sleep(1)
    #     po.phone1()
    #     sleep(1)
    #     po.baocun()

if __name__ == '__main__':
    unittest.main()